/**
 *
 * @author 老纳慢走
 * 
 */

$(document).ready(function() {
	
	$("input[type=radio][name=pay-way]").click(function() {
		if (this.id == 2) {  //全额支付
			setPaymethod('ONLINE_ALL');
		}else if (this.id == 1) {
			setPaymethod('ONLINE_PARTIALLY');
		}
	});
	
	$("input[type=radio][name=pay-way]").each(function(){
		var default_paymethod = $("#order_paymethod").val();
		if (this.id == 2 &&  default_paymethod == 'ONLINE_ALL'){
			this.checked = true;
		} else if (this.id == 1 &&  default_paymethod == 'ONLINE_PARTIALLY'){
			this.checked = true;
		}
	});

	$("#orderform").submit(function(e){
		
		if (!checkSubmitInfo()) {
			e.preventDefault();
			//alert("e.preventDefault();");
			return false;
		}
		showLoadingDiv();
		$("#goPay").attr("disabled","true");
		return true;
	});
	
});

function setPaymethod(pm){
	$("#order_paymethod").val(pm);
}

function checkSubmitInfo() {
	
	//var comments = $("#order_comments").val();
	//var paymethod = $("#order_paymethod").val();
	
	//alert( comments + ", " + paymethod);
	
	return true;
}

function flexible_animate() {
	$("#order_detail").toggleClass("b-b");
	
	$("#order_detail_items").animate({
		height : 'toggle',
		opacity : 'toggle',
		duration : "slow"
	}, function(){
		$("#order_detail").toggleClass("mi_down_arrow");
	});
}